Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid test in to_bool #90

Merged
merged 1 commit into from
Sep 27, 2024
Merged

Fix invalid test in to_bool #90

merged 1 commit into from
Sep 27, 2024

Conversation

dmarteau
Copy link
Member

@dmarteau dmarteau commented Sep 25, 2024

The value default_value is returned only if the tested vaiue is evaluated to False.
By default default_value is True then if the parameter is not given explicitely it is useless because we return the same value as the tested one.

If default_value si False:

  • If the tested value is a string then default_value has no effect
  • If the tested value is not a string and evaluated to False we return False
  • If the tested value is not a string and evaluated to True we return False

=> This means that this test only check if the tested value is a string and not the value we want to test !

In the source code, default_value is explicitely set to False only when testing a string (from os.getenv) and so default_value has - hopefully - no effect.

@dmarteau dmarteau requested a review from Gustry September 25, 2024 16:29
@dmarteau dmarteau merged commit 37bbe34 into master Sep 27, 2024
7 checks passed
@Gustry Gustry deleted the fix-to-bool branch September 27, 2024 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants